{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "之前说有机会就说下Linux下如何搭建C#版的交互编程，今天写篇文章还债^_^<br/>\n",
    "Win下比较简单，可以自己看官方文档<https://github.com/zabirauf/icsharp/wiki/Installation>下面逆天带搭建搭建下Linux下的环境（官方方法有问题）\n",
    "## CSharp交互式编程\n",
    "### 1.安装mono部分组件\n",
    "先看看官方仓库，如果你不是Ubuntu的自己切换下源\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130556833-1051104710.png \"官网来源\")\n",
    "\n",
    "安装mono部分组件，写段shell脚本，然后bash installmono.sh 直接执行\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130617167-1876033439.png \"执行脚本\")\n",
    "\n",
    "代码如下：\n",
    "```sh\n",
    "# add Ubuntu 18.04 repository\n",
    "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF\n",
    "echo \"deb https://download.mono-project.com/repo/ubuntu stable-bionic main\" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list\n",
    "# 更新一下\n",
    "sudo apt-get update -y\n",
    "# 安装 mono-complete\n",
    "sudo apt-get install mono-complete -y\n",
    "# 安装 mono-dbg\n",
    "sudo apt-get install mono-dbg -y                 \n",
    "# 安装 mono-runtime-dbg\n",
    "sudo apt-get install mono-runtime-dbg -y\n",
    "# 导入证书\n",
    "mozroots --import --machine --sync\n",
    "# 查看mono版本\n",
    "mono --version\n",
    "```\n",
    "看到这个就代表安装完成了\n",
    "\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130648422-1915896193.png \"安装完成\")\n",
    "\n",
    "### 2.安装Jupyter-notebook\n",
    "这部之前说过了，你安装了conda之后什么都有了，可以参考之前我写的一篇文章：\n",
    "\n",
    "<a href=\"https://www.cnblogs.com/dotnetcrazy/p/9158715.html\" target=\"_blank\">Anaconda For Linux</a>\n",
    "\n",
    "### 3.环境配置\n",
    "下载release包：\n",
    "<https://github.com/gyurisc/icsharp.kernel/releases/download/v1.0-beta/icsharp_kernel_v1.0.zip>\n",
    "\n",
    "然后移动到/opt/目录下（装软件一般都放这）\n",
    "现在你可以运行icsharp了：`mono icsharp.exe`\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130719613-619578564.png \"克隆\")\n",
    "\n",
    "### 4.编写代码\n",
    "新建一个C#的ipynb文件\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130738913-385829485.png)\n",
    "\n",
    "输入代码，shift+回车运行\n",
    "![](https://images2018.cnblogs.com/blog/1127869/201806/1127869-20180619130747577-122524170.png)\n",
    "\n",
    "其他的自己摸索摸索吧，先这样了～"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 * 1 = 1  \n",
       "1 * 2 = 2  2 * 2 = 4  \n",
       "1 * 3 = 3  2 * 3 = 6  3 * 3 = 9  \n",
       "1 * 4 = 4  2 * 4 = 8  3 * 4 = 12  4 * 4 = 16  \n",
       "1 * 5 = 5  2 * 5 = 10  3 * 5 = 15  4 * 5 = 20  5 * 5 = 25  \n",
       "1 * 6 = 6  2 * 6 = 12  3 * 6 = 18  4 * 6 = 24  5 * 6 = 30  6 * 6 = 36  \n",
       "1 * 7 = 7  2 * 7 = 14  3 * 7 = 21  4 * 7 = 28  5 * 7 = 35  6 * 7 = 42  7 * 7 = 49  \n",
       "1 * 8 = 8  2 * 8 = 16  3 * 8 = 24  4 * 8 = 32  5 * 8 = 40  6 * 8 = 48  7 * 8 = 56  8 * 8 = 64  \n",
       "1 * 9 = 9  2 * 9 = 18  3 * 9 = 27  4 * 9 = 36  5 * 9 = 45  6 * 9 = 54  7 * 9 = 63  8 * 9 = 72  9 * 9 = 81  \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "for (int i = 1; i <= 9; i++)\n",
    "{\n",
    "    for (int j = 1; j <= i; j++)\n",
    "    {\n",
    "        Console.Write($\"{j} * {i} = {i * j}  \");\n",
    "    }\n",
    "    Console.WriteLine();\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C#",
   "language": "csharp",
   "name": "icsharpkernel"
  },
  "language": "csharp",
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "csharp",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "6.0.0.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
